cmake_minimum_required(VERSION 3.8)
project(ui)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -std=c++17)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # comment the line when a copyright and license is added to all source files
  set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # comment the line when this package is in a git repo and when
  # a copyright and license is added to all source files
  set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()


macro(build_ui_event_plugin)
    set(moduleName ui_event_plugin)

    set(CMAKE_AUTOUIC ON)
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_AUTORCC ON)

    include(../common/cmake/add3rd.cmake)
    add3rds(utils muduo)

    # find dependencies
    find_package(ament_cmake REQUIRED)
    find_package(rviz_common REQUIRED)
    find_package(interface REQUIRED)

    include_directories(ui_event_plugin)

    #动态链接库
    add_library(${moduleName} SHARED
        ui_event_plugin/event_plugin.cpp
        ui_event_plugin/event_plugin.h
        ui_event_plugin/event_plugin.ui
    )

    ament_target_dependencies(${moduleName} rviz_common interface)

    target_link_libraries(${moduleName} muduo_net muduo_base)

    pluginlib_export_plugin_description_file(rviz_common ui_event_plugin/plugin_description.xml)

    install(TARGETS ${moduleName} DESTINATION lib/${PROJECT_NAME})
endmacro()

add_subdirectory(mesh)
add_subdirectory(ui_data_proxy)
#add_subdirectory(ui_event_plugin)
build_ui_event_plugin()

ament_package()
